home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / language / harvest.cpt / Harvest C / Tcl 6.2 / tclInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-12  |  31.5 KB  |  834 lines

  1. /*
  2.  * tclInt.h --
  3.  *
  4.  *    Declarations of things used internally by the Tcl interpreter.
  5.  *
  6.  * Copyright 1987-1991 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /user6/ouster/tcl/RCS/tclInt.h,v 1.66 91/12/06 11:09:30 ouster Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _TCLINT
  19. #define _TCLINT
  20.  
  21. #ifdef THINK_C
  22. #define macintosh
  23. #endif
  24.  
  25. /*
  26.  * Common include files needed by most of the Tcl source files are
  27.  * included here, so that system-dependent personalizations for the
  28.  * include files only have to be made in once place.  This results
  29.  * in a few extra includes, but greater modularity.  The order of
  30.  * the three groups of #includes is important.  For example, stdio.h
  31.  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
  32.  * needed by stdlib.h in some configurations.
  33.  */
  34.  
  35. #include <stdio.h>
  36.  
  37. /*
  38.  * Macro to use instead of "void" for arguments that must have
  39.  * type "void *" in ANSI C;  maps them to type "char *" in
  40.  * non-ANSI systems.  This macro may be used in some of the include
  41.  * files below, which is why it is defined here.
  42.  */
  43.  
  44. #define VOID char
  45.  
  46. #include <ctype.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49.  
  50. #ifdef macintosh
  51. #    include <StdArg.h>
  52. #else
  53. #    include <varargs.h>
  54. #endif
  55.  
  56. #ifndef _TCL
  57. #include "tcl.h"
  58. #endif
  59. #ifndef _TCLHASH
  60. #include "tclHash.h"
  61. #endif
  62. #ifndef _REGEXP
  63. #include "regexp.h"
  64. #endif
  65.  
  66. /*
  67.  * At present (12/91) not all stdlib.h implementations declare strtod.
  68.  * The declaration below is here to ensure that it's declared, so that
  69.  * the compiler won't take the default approach of assuming it returns
  70.  * an int.  There's no ANSI prototype for it because there would end
  71.  * up being too many conflicts with slightly-different prototypes.
  72.  */
  73.  
  74. extern double strtod();
  75.  
  76. /*
  77.  *----------------------------------------------------------------
  78.  * Data structures related to variables.   These are used primarily
  79.  * in tclVar.c
  80.  *----------------------------------------------------------------
  81.  */
  82.  
  83. /*
  84.  * The following structure defines a variable trace, which is used to
  85.  * invoke a specific C procedure whenever certain operations are performed
  86.  * on a variable.
  87.  */
  88.  
  89. typedef struct VarTrace {
  90.     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
  91.                  * by flags are performed on variable. */
  92.     ClientData clientData;    /* Argument to pass to proc. */
  93.     int flags;            /* What events the trace procedure is
  94.                  * interested in:  OR-ed combination of
  95.                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
  96.                  * TCL_TRACE_UNSETS. */
  97.     struct VarTrace *nextPtr;    /* Next in list of traces associated with
  98.                  * a particular variable. */
  99. } VarTrace;
  100.  
  101. /*
  102.  * When a variable trace is active (i.e. its associated procedure is
  103.  * executing), one of the following structures is linked into a list
  104.  * associated with the variable's interpreter.  The information in
  105.  * the structure is needed in order for Tcl to behave reasonably
  106.  * if traces are deleted while traces are active.
  107.  */
  108.  
  109. typedef struct ActiveVarTrace {
  110.     struct ActiveVarTrace *nextPtr;
  111.                 /* Next in list of all active variable
  112.                  * traces for the interpreter, or NULL
  113.                  * if no more. */
  114.     VarTrace *nextTracePtr;    /* Next trace to check after current
  115.                  * trace procedure returns;  if this
  116.                  * trace gets deleted, must update pointer
  117.                  * to avoid using free'd memory. */
  118. } ActiveVarTrace;
  119.  
  120. /*
  121.  * The following structure describes an enumerative search in progress on
  122.  * an array variable;  this are invoked with options to the "array"
  123.  * command.
  124.  */
  125.  
  126. typedef struct ArraySearch {
  127.     int id;            /* Integer id used to distinguish among
  128.                  * multiple concurrent searches for the
  129.                  * same array. */
  130.     struct Var *varPtr;        /* Pointer to array variable that's being
  131.                  * searched. */
  132.     Tcl_HashSearch search;    /* Info kept by the hash module about
  133.                  * progress through the array. */
  134.     Tcl_HashEntry *nextEntry;    /* Non-null means this is the next element
  135.                  * to be enumerated (it's leftover from
  136.                  * the Tcl_FirstHashEntry call or from
  137.                  * an "array anymore" command).  NULL
  138.                  * means must call Tcl_NextHashEntry
  139.                  * to get value to return. */
  140.     struct ArraySearch *nextPtr;/* Next in list of all active searches
  141.                  * for this variable, or NULL if this is
  142.                  * the last one. */
  143. } ArraySearch;
  144.  
  145. /*
  146.  * The structure below defines a variable, which associates a string name
  147.  * with a string value.  Pointers to these structures are kept as the
  148.  * values of hash table entries, and the name of each variable is stored
  149.  * in the hash entry.
  150.  */
  151.  
  152. typedef struct Var {
  153.     int valueLength;        /* Holds the number of non-null bytes
  154.                  * actually occupied by the variable's
  155.                  * current value in value.string (extra
  156.                  * space is sometimes left for expansion).
  157.                  * For array and global variables this is
  158.                  * meaningless. */
  159.     int valueSpace;        /* Total number of bytes of space allocated
  160.                  * at value. */
  161.     int upvarUses;        /* Counts number of times variable is
  162.                  * is referenced via global or upvar variables
  163.                  * (i.e. how many variables have "upvarPtr"
  164.                  * pointing to this variable).  Variable
  165.                  * can't be deleted until this count reaches
  166.                  * 0. */
  167.     VarTrace *tracePtr;        /* First in list of all traces set for this
  168.                  * variable. */
  169.     ArraySearch *searchPtr;    /* First in list of all searches active
  170.                  * for this variable, or NULL if none. */
  171.     int flags;            /* Miscellaneous bits of information about
  172.                  * variable.  See below for definitions. */
  173.     union {
  174.     char string[4];        /* String value of variable.  The actual
  175.                  * length of this field is given by the
  176.                  * valueSpace field above. */
  177.     Tcl_HashTable *tablePtr;/* For array variables, this points to
  178.                  * information about the hash table used
  179.                  * to implement the associative array. 
  180.                  * Points to malloc-ed data. */
  181.     Tcl_HashEntry *upvarPtr;
  182.                 /* If this is a global variable being
  183.                  * referred to in a procedure, or a variable
  184.                  * created by "upvar", this field points to
  185.                  * the hash table entry for the higher-level
  186.                  * variable. */
  187.     } value;            /* MUST BE LAST FIELD IN STRUCTURE!!! */
  188. } Var;
  189.  
  190. /*
  191.  * Flag bits for variables:
  192.  *
  193.  * VAR_ARRAY    -        1 means this is an array variable rather
  194.  *                than a scalar variable.
  195.  * VAR_UPVAR -             1 means this variable just contains a
  196.  *                pointer to another variable that has the
  197.  *                real value.  Variables like this come
  198.  *                about through the "upvar" and "global"
  199.  *                commands.
  200.  * VAR_UNDEFINED -        1 means that the variable is currently
  201.  *                undefined.  Undefined variables usually
  202.  *                go away completely, but if an undefined
  203.  *                variable has a trace on it, or if it is
  204.  *                a global variable being used by a procedure,
  205.  *                then it stays around even when undefined.
  206.  * VAR_ELEMENT_ACTIVE -        Used only in array variables;  1 means that
  207.  *                an element of the array is currently being
  208.  *                manipulated in some way, so that it isn't
  209.  *                safe to delete the whole array.
  210.  * VAR_TRACE_ACTIVE -        1 means that trace processing is currently
  211.  *                underway for a read or write access, so
  212.  *                _new read or write accesses should not cause
  213.  *                trace procedures to be called and the
  214.  *                variable can't be deleted.
  215.  */
  216.  
  217. #define VAR_ARRAY        1
  218. #define VAR_UPVAR        2
  219. #define VAR_UNDEFINED        4
  220. #define VAR_ELEMENT_ACTIVE    0x10
  221. #define VAR_TRACE_ACTIVE    0x20
  222. #define VAR_SEARCHES_POSSIBLE    0x40
  223.  
  224. /*
  225.  *----------------------------------------------------------------
  226.  * Data structures related to procedures.   These are used primarily
  227.  * in tclProc.c
  228.  *----------------------------------------------------------------
  229.  */
  230.  
  231. /*
  232.  * The structure below defines an argument to a procedure, which
  233.  * consists of a name and an (optional) default value.
  234.  */
  235.  
  236. typedef struct Arg {
  237.     struct Arg *nextPtr;    /* Next argument for this procedure,
  238.                  * or NULL if this is the last argument. */
  239.     char *defValue;        /* Pointer to arg's default value, or NULL
  240.                  * if no default value. */
  241.     char name[4];        /* Name of argument starts here.  The name
  242.                  * is followed by space for the default,
  243.                  * if there is one.  The actual size of this
  244.                  * field will be as large as necessary to
  245.                  * hold both name and default value.  THIS
  246.                  * MUST BE THE LAST FIELD IN THE STRUCTURE!! */
  247. } Arg;
  248.  
  249. /*
  250.  * The structure below defines a command procedure, which consists of
  251.  * a collection of Tcl commands plus information about arguments and
  252.  * variables.
  253.  */
  254.  
  255. typedef struct Proc {
  256.     struct Interp *iPtr;    /* Interpreter for which this command
  257.                  * is defined. */
  258.     char *command;        /* Command that constitutes the body of
  259.                  * the procedure (dynamically allocated). */
  260.     Arg *argPtr;        /* Pointer to first of procedure's formal
  261.                  * arguments, or NULL if none. */
  262. } Proc;
  263.  
  264. /*
  265.  * The structure below defines a command trace.  This is used to allow Tcl
  266.  * clients to find out whenever a command is about to be executed.
  267.  */
  268.  
  269. typedef struct Trace {
  270.     int level;            /* Only trace commands at nesting level
  271.                  * less than or equal to this. */
  272.     Tcl_CmdTraceProc *proc;    /* Procedure to call to trace command. */
  273.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  274.     struct Trace *nextPtr;    /* Next in list of traces for this interp. */
  275. } Trace;
  276.  
  277. /*
  278.  * The structure below defines a frame, which is a procedure invocation.
  279.  * These structures exist only while procedures are being executed, and
  280.  * provide a sort of call stack.
  281.  */
  282.  
  283. typedef struct CallFrame {
  284.     Tcl_HashTable varTable;    /* Hash table containing all of procedure's
  285.                  * local variables. */
  286.     int level;            /* Level of this procedure, for "uplevel"
  287.                  * purposes (i.e. corresponds to nesting of
  288.                  * callerVarPtr's, not callerPtr's).  1 means
  289.                  * outer-most procedure, 0 means top-level. */
  290.     int argc;            /* This and argv below describe name and
  291.                  * arguments for this procedure invocation. */
  292.     char **argv;        /* Array of arguments. */
  293.     struct CallFrame *callerPtr;
  294.                 /* Frame of procedure that invoked this one
  295.                  * (NULL if level == 1). */
  296.     struct CallFrame *callerVarPtr;
  297.                 /* Frame used by caller for accessing local
  298.                  * variables (same as callerPtr unless an
  299.                  * "uplevel" command was active in the
  300.                  * caller).  This field is used in the
  301.                  * implementation of "uplevel". */
  302. } CallFrame;
  303.  
  304. /*
  305.  * The structure below defines one history event (a previously-executed
  306.  * command that can be re-executed in whole or in part).
  307.  */
  308.  
  309. typedef struct {
  310.     char *command;        /* String containing previously-executed
  311.                  * command. */
  312.     int bytesAvl;        /* Total # of bytes available at *event (not
  313.                  * all are necessarily in use now). */
  314. } HistoryEvent;
  315.  
  316. /*
  317.  *----------------------------------------------------------------
  318.  * Data structures related to history.   These are used primarily
  319.  * in tclHistory.c
  320.  *----------------------------------------------------------------
  321.  */
  322.  
  323. /*
  324.  * The structure below defines a pending revision to the most recent
  325.  * history event.  Changes are linked together into a list and applied
  326.  * during the next call to Tcl_RecordHistory.  See the comments at the
  327.  * beginning of tclHistory.c for information on revisions.
  328.  */
  329.  
  330. typedef struct HistoryRev {
  331.     int firstIndex;        /* Index of the first byte to replace in
  332.                  * current history event. */
  333.     int lastIndex;        /* Index of last byte to replace in
  334.                  * current history event. */
  335.     int newSize;        /* Number of bytes in newBytes. */
  336.     char *newBytes;        /* Replacement for the range given by
  337.                  * firstIndex and lastIndex. */
  338.     struct HistoryRev *nextPtr;    /* Next in chain of revisions to apply, or
  339.                  * NULL for end of list. */
  340. } HistoryRev;
  341.  
  342. /*
  343.  *----------------------------------------------------------------
  344.  * Data structures related to files.  These are used primarily in
  345.  * tclUnixUtil.c and tclUnixAZ.c.
  346.  *----------------------------------------------------------------
  347.  */
  348.  
  349. /*
  350.  * The data structure below defines an open file (or connection to
  351.  * a process pipeline) as returned by the "open" command.
  352.  */
  353.  
  354. typedef struct OpenFile {
  355.     FILE *f;            /* Stdio file to use for reading and/or
  356.                  * writing. */
  357.     FILE *f2;            /* Normally NULL.  In the special case of
  358.                  * a command pipeline with pipes for both
  359.                  * input and output, this is a stdio file
  360.                  * to use for writing to the pipeline. */
  361.     int readable;        /* Non-zero means file may be read. */
  362.     int writable;        /* Non-zero means file may be written. */
  363.     int numPids;        /* If this is a connection to a process
  364.                  * pipeline, gives number of processes
  365.                  * in pidPtr array below;  otherwise it
  366.                  * is 0. */
  367.     int *pidPtr;        /* Pointer to malloc-ed array of child
  368.                  * process ids (numPids of them), or NULL
  369.                  * if this isn't a connection to a process
  370.                  * pipeline. */
  371.     int errorId;        /* File id of file that receives error
  372.                  * output from pipeline.  -1 means not
  373.                  * used (i.e. this is a normal file). */
  374. } OpenFile;
  375.  
  376. /*
  377.  *----------------------------------------------------------------
  378.  * This structure defines an interpreter, which is a collection of
  379.  * commands plus other state information related to interpreting
  380.  * commands, such as variable storage.  Primary responsibility for
  381.  * this data structure is in tclBasic.c, but almost every Tcl
  382.  * source file uses something in here.
  383.  *----------------------------------------------------------------
  384.  */
  385.  
  386. typedef struct Command {
  387.     Tcl_CmdProc *proc;        /* Procedure to process command. */
  388.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  389.     Tcl_CmdDeleteProc *deleteProc;
  390.                 /* Procedure to invoke when deleting
  391.                  * command. */
  392. } Command;
  393.  
  394. #define CMD_SIZE(nameLength) ((unsigned) sizeof(Command) + nameLength - 3)
  395.  
  396. typedef struct Interp {
  397.  
  398.     /*
  399.      * Note:  the first three fields must match exactly the fields in
  400.      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
  401.      * change the other.
  402.      */
  403.  
  404.     char *result;        /* Points to result returned by last
  405.                  * command. */
  406.     Tcl_FreeProc *freeProc;    /* Zero means result is statically allocated.
  407.                  * If non-zero, gives address of procedure
  408.                  * to invoke to free the result.  Must be
  409.                  * freed by Tcl_Eval before executing next
  410.                  * command. */
  411.     int errorLine;        /* When TCL_ERROR is returned, this gives
  412.                  * the line number within the command where
  413.                  * the error occurred (1 means first line). */
  414.     Tcl_HashTable commandTable;    /* Contains all of the commands currently
  415.                  * registered in this interpreter.  Indexed
  416.                  * by strings; values have type (Command *). */
  417.  
  418.     /*
  419.      * Information related to procedures and variables.  See tclProc.c
  420.      * and tclvar.c for usage.
  421.      */
  422.  
  423.     Tcl_HashTable globalTable;    /* Contains all global variables for
  424.                  * interpreter. */
  425.     int numLevels;        /* Keeps track of how many nested calls to
  426.                  * Tcl_Eval are in progress for this
  427.                  * interpreter.  It's used to delay deletion
  428.                  * of the table until all Tcl_Eval invocations
  429.                  * are completed. */
  430.     CallFrame *framePtr;    /* If a procedure is being executed, this
  431.                  * points to the call frame for the current
  432.                  * procedure (most recently-called).  NULL
  433.                  * means no procedure is active. */
  434.     CallFrame *varFramePtr;    /* Points to the call frame whose variables
  435.                  * are currently in use (same as framePtr
  436.                  * unless an "uplevel" command is being
  437.                  * executed).  NULL means no procedure is
  438.                  * active or "uplevel 0" is being exec'ed. */
  439.     ActiveVarTrace *activeTracePtr;
  440.                 /* First in list of active traces for interp,
  441.                  * or NULL if no active traces. */
  442.  
  443.     /*
  444.      * Information related to history:
  445.      */
  446.  
  447.     int numEvents;        /* Number of previously-executed commands
  448.                  * to retain. */
  449.     HistoryEvent *events;    /* Array containing numEvents entries
  450.                  * (dynamically allocated). */
  451.     int curEvent;        /* Index into events of place where current
  452.                  * (or most recent) command is recorded. */
  453.     int curEventNum;        /* Event number associated with the slot
  454.                  * given by curEvent. */
  455.     HistoryRev *revPtr;        /* First in list of pending revisions. */
  456.     char *historyFirst;        /* First char. of current command executed
  457.                  * from history module or NULL if none. */
  458.     int revDisables;        /* 0 means history revision OK;  > 0 gives
  459.                  * a count of number of times revision has
  460.                  * been disabled. */
  461.     char *evalFirst;        /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval
  462.                  * sets this field to point to the first
  463.                  * char. of text from which the current
  464.                  * command came.  Otherwise Tcl_Eval sets
  465.                  * this to NULL. */
  466.     char *evalLast;        /* Similar to evalFirst, except points to
  467.                  * last character of current command. */
  468.  
  469.     /*
  470.      * Information used by Tcl_AppendResult to keep track of partial
  471.      * results.  See Tcl_AppendResult code for details.
  472.      */
  473.  
  474.     char *appendResult;        /* Storage space for results generated
  475.                  * by Tcl_AppendResult.  Malloc-ed.  NULL
  476.                  * means not yet allocated. */
  477.     int appendAvl;        /* Total amount of space available at
  478.                  * partialResult. */
  479.     int appendUsed;        /* Number of non-null bytes currently
  480.                  * stored at partialResult. */
  481.  
  482.     /*
  483.      * Information related to files.  See tclUnixAZ.c and tclUnixUtil.c
  484.      * for details.
  485.      */
  486.  
  487.     int numFiles;        /* Number of entries in filePtrArray
  488.                  * below.  0 means array hasn't been
  489.                  * created yet. */
  490.     OpenFile **filePtrArray;    /* Pointer to malloc-ed array of pointers
  491.                  * to information about open files.  Entry
  492.                  * N corresponds to the file with fileno N.
  493.                  * If an entry is NULL then the corresponding
  494.                  * file isn't open.  If filePtrArray is NULL
  495.                  * it means no files have been used, so even
  496.                  * stdin/stdout/stderr entries haven't been
  497.                  * setup yet. */
  498.     /*
  499.      * A cache of compiled regular expressions.  See TclCompileRegexp
  500.      * in tclUtil.c for details.
  501.      */
  502.  
  503. #define NUM_REGEXPS 5
  504.     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
  505.                  * regular expression patterns.  NULL
  506.                  * means that this slot isn't used.
  507.                  * Malloc-ed. */
  508.     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
  509.                  * corresponding entry in patterns. */
  510.     regexp *regexps[NUM_REGEXPS];
  511.                 /* Compiled forms of above strings.  Also
  512.                  * malloc-ed, or NULL if not in use yet. */
  513.  
  514.  
  515.     /*
  516.      * Miscellaneous information:
  517.      */
  518.  
  519.     int cmdCount;        /* Total number of times a command procedure
  520.                  * has been called for this interpreter. */
  521.     int noEval;            /* Non-zero means no commands should actually
  522.                  * be executed:  just parse only.  Used in
  523.                  * expressions when the result is already
  524.                  * determined. */
  525.     char *scriptFile;        /* NULL means there is no nested source
  526.                  * command active;  otherwise this points to
  527.                  * the name of the file being sourced (it's
  528.                  * not malloc-ed:  it points to an argument
  529.                  * to Tcl_EvalFile. */
  530.     int flags;            /* Various flag bits.  See below. */
  531.     Trace *tracePtr;        /* List of traces for this interpreter. */
  532.     char resultSpace[TCL_RESULT_SIZE+1];
  533.                 /* Static space for storing small results. */
  534. } Interp;
  535.  
  536. /*
  537.  * Flag bits for Interp structures:
  538.  *
  539.  * DELETED:        Non-zero means the interpreter has been deleted:
  540.  *            don't process any more commands for it, and destroy
  541.  *            the structure as soon as all nested invocations of
  542.  *            Tcl_Eval are done.
  543.  * ERR_IN_PROGRESS:    Non-zero means an error unwind is already in progress.
  544.  *            Zero means a command proc has been invoked since last
  545.  *            error occured.
  546.  * ERR_ALREADY_LOGGED:    Non-zero means information has already been logged
  547.  *            in $errorInfo for the current Tcl_Eval instance,
  548.  *            so Tcl_Eval needn't log it (used to implement the
  549.  *            "error message log" command).
  550.  * ERROR_CODE_SET:    Non-zero means that Tcl_SetErrorCode has been
  551.  *            called to record information for the current
  552.  *            error.  Zero means Tcl_Eval must clear the
  553.  *            errorCode variable if an error is returned.
  554.  */
  555.  
  556. #define DELETED            1
  557. #define ERR_IN_PROGRESS        2
  558. #define ERR_ALREADY_LOGGED    4
  559. #define ERROR_CODE_SET        8
  560.  
  561. /*
  562.  *----------------------------------------------------------------
  563.  * Data structures related to command parsing.   These are used in
  564.  * tclParse.c and its clients.
  565.  *----------------------------------------------------------------
  566.  */
  567.  
  568. /*
  569.  * The following data structure is used by various parsing procedures
  570.  * to hold information about where to store the results of parsing
  571.  * (e.g. the substituted contents of a quoted argument, or the result
  572.  * of a nested command).  At any given time, the space available
  573.  * for output is fixed, but a procedure may be called to expand the
  574.  * space available if the current space runs out.
  575.  */
  576.  
  577. typedef struct ParseValue {
  578.     char *buffer;        /* Address of first character in
  579.                  * output buffer. */
  580.     char *next;            /* Place to store next character in
  581.                  * output buffer. */
  582.     char *end;            /* Address of the last usable character
  583.                  * in the buffer. */
  584.     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
  585.                 /* Procedure to call when space runs out;
  586.                  * it will make more space. */
  587.     ClientData clientData;    /* Arbitrary information for use of
  588.                  * expandProc. */
  589. } ParseValue;
  590.  
  591. /*
  592.  * A table used to classify input characters to assist in parsing
  593.  * Tcl commands.  The table should be indexed with a signed character
  594.  * using the CHAR_TYPE macro.  The character may have a negative
  595.  * value.
  596.  */
  597.  
  598. extern char tclTypeTable[];
  599. #define CHAR_TYPE(c) (tclTypeTable+128)[c]
  600.  
  601. /*
  602.  * Possible values returned by CHAR_TYPE:
  603.  *
  604.  * TCL_NORMAL -        All characters that don't have special significance
  605.  *            to the Tcl language.
  606.  * TCL_SPACE -        Character is space, tab, or return.
  607.  * TCL_COMMAND_END -    Character is newline or null or semicolon or
  608.  *            close-bracket.
  609.  * TCL_QUOTE -        Character is a double-quote.
  610.  * TCL_OPEN_BRACKET -    Character is a "[".
  611.  * TCL_OPEN_BRACE -    Character is a "{".
  612.  * TCL_CLOSE_BRACE -    Character is a "}".
  613.  * TCL_BACKSLASH -    Character is a "\".
  614.  * TCL_DOLLAR -        Character is a "$".
  615.  */
  616.  
  617. #define TCL_NORMAL        0
  618. #define TCL_SPACE        1
  619. #define TCL_COMMAND_END        2
  620. #define TCL_QUOTE        3
  621. #define TCL_OPEN_BRACKET    4
  622. #define TCL_OPEN_BRACE        5
  623. #define TCL_CLOSE_BRACE        6
  624. #define TCL_BACKSLASH        7
  625. #define TCL_DOLLAR        8
  626.  
  627. /*
  628.  * Additional flags passed to Tcl_Eval.  See tcl.h for other flags to
  629.  * Tcl_Eval;  these ones are only used internally by Tcl.
  630.  *
  631.  * TCL_RECORD_BOUNDS    Tells Tcl_Eval to record information in the
  632.  *            evalFirst and evalLast fields for each command
  633.  *            executed directly from the string (top-level
  634.  *            commands and those from command substitution).
  635.  */
  636.  
  637. #define TCL_RECORD_BOUNDS    0x100
  638.  
  639. /*
  640.  * Maximum number of levels of nesting permitted in Tcl commands.
  641.  */
  642.  
  643. #define MAX_NESTING_DEPTH    100
  644.  
  645. /*
  646.  * Variables shared among Tcl modules but not used by the outside
  647.  * world:
  648.  */
  649.  
  650. extern char *        tclRegexpError;
  651.  
  652. /*
  653.  *----------------------------------------------------------------
  654.  * Procedures shared among Tcl modules but not used by the outside
  655.  * world:
  656.  *----------------------------------------------------------------
  657.  */
  658.  
  659. extern void        panic();
  660. extern regexp *        TclCompileRegexp _ANSI_ARGS_((Tcl_Interp *interp,
  661.                 char *string));
  662. extern void        TclCopyAndCollapse _ANSI_ARGS_((int count, char *src,
  663.                 char *dst));
  664. extern void        TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
  665.                 Tcl_HashTable *tablePtr));
  666. extern void        TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
  667.                 int needed));
  668. extern int        TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
  669.                 char *list, char **elementPtr, char **nextPtr,
  670.                 int *sizePtr, int *bracePtr));
  671. extern Proc *        TclFindProc _ANSI_ARGS_((Interp *iPtr,
  672.                 char *procName));
  673. extern int        TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
  674.                 char *string, CallFrame **framePtrPtr));
  675. extern int        TclGetListIndex _ANSI_ARGS_((Tcl_Interp *interp,
  676.                 char *string, int *indexPtr));
  677. extern int        TclGetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
  678.                 char *string, OpenFile **filePtrPtr));
  679. extern Proc *        TclIsProc _ANSI_ARGS_((Command *cmdPtr));
  680. extern void        TclMakeFileTable _ANSI_ARGS_((Interp *iPtr,
  681.                 int index));
  682. extern int        TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
  683.                 char *string, char **termPtr, ParseValue *pvPtr));
  684. extern int        TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
  685.                 char *string, int flags, char **termPtr,
  686.                 ParseValue *pvPtr));
  687. extern int        TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
  688.                 char *string, int termChar, int flags,
  689.                 char **termPtr, ParseValue *pvPtr));
  690. extern int        TclParseWords _ANSI_ARGS_((Tcl_Interp *interp,
  691.                 char *string, int flags, int maxWords,
  692.                 char **termPtr, int *argcPtr, char **argv,
  693.                 ParseValue *pvPtr));
  694. extern void        TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
  695. extern char *        TclWordEnd _ANSI_ARGS_((char *start, int nested));
  696.  
  697. /*
  698.  *----------------------------------------------------------------
  699.  * Command procedures in the generic core:
  700.  *----------------------------------------------------------------
  701.  */
  702.  
  703. extern int    Tcl_AppendCmd _ANSI_ARGS_((ClientData clientData,
  704.             Tcl_Interp *interp, int argc, char **argv));
  705. extern int    Tcl_ArrayCmd _ANSI_ARGS_((ClientData clientData,
  706.             Tcl_Interp *interp, int argc, char **argv));
  707. extern int    Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
  708.             Tcl_Interp *interp, int argc, char **argv));
  709. extern int    Tcl_CaseCmd _ANSI_ARGS_((ClientData clientData,
  710.             Tcl_Interp *interp, int argc, char **argv));
  711. extern int    Tcl_CatchCmd _ANSI_ARGS_((ClientData clientData,
  712.             Tcl_Interp *interp, int argc, char **argv));
  713. extern int    Tcl_ConcatCmd _ANSI_ARGS_((ClientData clientData,
  714.             Tcl_Interp *interp, int argc, char **argv));
  715. extern int    Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
  716.             Tcl_Interp *interp, int argc, char **argv));
  717. extern int    Tcl_ErrorCmd _ANSI_ARGS_((ClientData clientData,
  718.             Tcl_Interp *interp, int argc, char **argv));
  719. extern int    Tcl_EvalCmd _ANSI_ARGS_((ClientData clientData,
  720.             Tcl_Interp *interp, int argc, char **argv));
  721. extern int    Tcl_ExprCmd _ANSI_ARGS_((ClientData clientData,
  722.             Tcl_Interp *interp, int argc, char **argv));
  723. extern int    Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
  724.             Tcl_Interp *interp, int argc, char **argv));
  725. extern int    Tcl_ForeachCmd _ANSI_ARGS_((ClientData clientData,
  726.             Tcl_Interp *interp, int argc, char **argv));
  727. extern int    Tcl_FormatCmd _ANSI_ARGS_((ClientData clientData,
  728.             Tcl_Interp *interp, int argc, char **argv));
  729. extern int    Tcl_GlobalCmd _ANSI_ARGS_((ClientData clientData,
  730.             Tcl_Interp *interp, int argc, char **argv));
  731. extern int    Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData,
  732.             Tcl_Interp *interp, int argc, char **argv));
  733. extern int    Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
  734.             Tcl_Interp *interp, int argc, char **argv));
  735. extern int    Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
  736.             Tcl_Interp *interp, int argc, char **argv));
  737. extern int    Tcl_InfoCmd _ANSI_ARGS_((ClientData clientData,
  738.             Tcl_Interp *interp, int argc, char **argv));
  739. extern int    Tcl_JoinCmd _ANSI_ARGS_((ClientData clientData,
  740.             Tcl_Interp *interp, int argc, char **argv));
  741. extern int    Tcl_LappendCmd _ANSI_ARGS_((ClientData clientData,
  742.             Tcl_Interp *interp, int argc, char **argv));
  743. extern int    Tcl_LindexCmd _ANSI_ARGS_((ClientData clientData,
  744.             Tcl_Interp *interp, int argc, char **argv));
  745. extern int    Tcl_LinsertCmd _ANSI_ARGS_((ClientData clientData,
  746.             Tcl_Interp *interp, int argc, char **argv));
  747. extern int    Tcl_LlengthCmd _ANSI_ARGS_((ClientData clientData,
  748.             Tcl_Interp *interp, int argc, char **argv));
  749. extern int    Tcl_ListCmd _ANSI_ARGS_((ClientData clientData,
  750.             Tcl_Interp *interp, int argc, char **argv));
  751. extern int    Tcl_LrangeCmd _ANSI_ARGS_((ClientData clientData,
  752.             Tcl_Interp *interp, int argc, char **argv));
  753. extern int    Tcl_LreplaceCmd _ANSI_ARGS_((ClientData clientData,
  754.             Tcl_Interp *interp, int argc, char **argv));
  755. extern int    Tcl_LsearchCmd _ANSI_ARGS_((ClientData clientData,
  756.             Tcl_Interp *interp, int argc, char **argv));
  757. extern int    Tcl_LsortCmd _ANSI_ARGS_((ClientData clientData,
  758.             Tcl_Interp *interp, int argc, char **argv));
  759. extern int    Tcl_ProcCmd _ANSI_ARGS_((ClientData clientData,
  760.             Tcl_Interp *interp, int argc, char **argv));
  761. extern int    Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
  762.             Tcl_Interp *interp, int argc, char **argv));
  763. extern int    Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
  764.             Tcl_Interp *interp, int argc, char **argv));
  765. extern int    Tcl_RenameCmd _ANSI_ARGS_((ClientData clientData,
  766.             Tcl_Interp *interp, int argc, char **argv));
  767. extern int    Tcl_ReturnCmd _ANSI_ARGS_((ClientData clientData,
  768.             Tcl_Interp *interp, int argc, char **argv));
  769. extern int    Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
  770.             Tcl_Interp *interp, int argc, char **argv));
  771. extern int    Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
  772.             Tcl_Interp *interp, int argc, char **argv));
  773. extern int    Tcl_SplitCmd _ANSI_ARGS_((ClientData clientData,
  774.             Tcl_Interp *interp, int argc, char **argv));
  775. extern int    Tcl_StringCmd _ANSI_ARGS_((ClientData clientData,
  776.             Tcl_Interp *interp, int argc, char **argv));
  777. extern int    Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
  778.             Tcl_Interp *interp, int argc, char **argv));
  779. extern int    Tcl_UnsetCmd _ANSI_ARGS_((ClientData clientData,
  780.             Tcl_Interp *interp, int argc, char **argv));
  781. extern int    Tcl_UplevelCmd _ANSI_ARGS_((ClientData clientData,
  782.             Tcl_Interp *interp, int argc, char **argv));
  783. extern int    Tcl_UpvarCmd _ANSI_ARGS_((ClientData clientData,
  784.             Tcl_Interp *interp, int argc, char **argv));
  785. extern int    Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
  786.             Tcl_Interp *interp, int argc, char **argv));
  787. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  788.             Tcl_Interp *interp, int argc, char **argv));
  789. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  790.             Tcl_Interp *interp, int argc, char **argv));
  791.  
  792. /*
  793.  *----------------------------------------------------------------
  794.  * Command procedures in the UNIX core:
  795.  *----------------------------------------------------------------
  796.  */
  797.  
  798. extern int    Tcl_CdCmd _ANSI_ARGS_((ClientData clientData,
  799.             Tcl_Interp *interp, int argc, char **argv));
  800. extern int    Tcl_CloseCmd _ANSI_ARGS_((ClientData clientData,
  801.             Tcl_Interp *interp, int argc, char **argv));
  802. extern int    Tcl_EofCmd _ANSI_ARGS_((ClientData clientData,
  803.             Tcl_Interp *interp, int argc, char **argv));
  804. extern int    Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
  805.             Tcl_Interp *interp, int argc, char **argv));
  806. extern int    Tcl_ExitCmd _ANSI_ARGS_((ClientData clientData,
  807.             Tcl_Interp *interp, int argc, char **argv));
  808. extern int    Tcl_FileCmd _ANSI_ARGS_((ClientData clientData,
  809.             Tcl_Interp *interp, int argc, char **argv));
  810. extern int    Tcl_FlushCmd _ANSI_ARGS_((ClientData clientData,
  811.             Tcl_Interp *interp, int argc, char **argv));
  812. extern int    Tcl_GetsCmd _ANSI_ARGS_((ClientData clientData,
  813.             Tcl_Interp *interp, int argc, char **argv));
  814. extern int    Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
  815.             Tcl_Interp *interp, int argc, char **argv));
  816. extern int    Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
  817.             Tcl_Interp *interp, int argc, char **argv));
  818. extern int    Tcl_PutsCmd _ANSI_ARGS_((ClientData clientData,
  819.             Tcl_Interp *interp, int argc, char **argv));
  820. extern int    Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
  821.             Tcl_Interp *interp, int argc, char **argv));
  822. extern int    Tcl_ReadCmd _ANSI_ARGS_((ClientData clientData,
  823.             Tcl_Interp *interp, int argc, char **argv));
  824. extern int    Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
  825.             Tcl_Interp *interp, int argc, char **argv));
  826. extern int    Tcl_SourceCmd _ANSI_ARGS_((ClientData clientData,
  827.             Tcl_Interp *interp, int argc, char **argv));
  828. extern int    Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
  829.             Tcl_Interp *interp, int argc, char **argv));
  830. extern int    Tcl_TimeCmd _ANSI_ARGS_((ClientData clientData,
  831.             Tcl_Interp *interp, int argc, char **argv));
  832.  
  833. #endif /* _TCLINT */
  834.